// home模块的仓库
import { reqCategoryList, resGetBannerList } from '@/api'

const state = {
    categoryList: [],
    BannerList: []
};
const mutations = {
    CATEGORYLIST(state, categoryList) {
        state.categoryList = categoryList
    },
    // home页面的轮播图
    GETBANNERLIST(state, BannerList) {
        state.BannerList = BannerList
    }
};
const actions = {
    // 通过API里面的接口函数调用,向服务器发请求，获取数据
    async categoryList({ commit }) {
        let result = await reqCategoryList();
        // console.log(result);
        if (result.code == 200) {
            commit('CATEGORYLIST', result.data)
        }
    },
    // home页面的轮播图
    async getBannerList({ commit }) {
        let result = await resGetBannerList();
        console.log(result);
        if (result.code == 200) {
            commit('GETBANNERLIST', result.data)
        }
    }


};
const getters = {};

export default {
    // 为当前模块开启命名空间
    namespaced: true,

    state,
    mutations,
    actions,
    getters
}